package com.yzf.demo.demo.io;

import java.io.*;

/**
 * Created by 于占峰 on 2020/4/5/005.
 */
public class TestDemo {

    public static void main(String[] args) throws IOException {
        int i = 0;
        //磁盘IO
        try {
            FileInputStream fileInputStream = new FileInputStream("G:/HellWorld.txt");
            while ((i = fileInputStream.read()) != -1) {
                System.out.print((char) i);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        //内存
        String str = "HellWord";
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes());
        i = 0;
        while ((i = byteArrayInputStream.read()) != -1) {
            System.out.print((char) i);
        }
        byteArrayInputStream.close();//关闭输入流
        //键盘 读取控制台输入的内容 打印出来
        InputStream inputStream = System.in;
        i = 0;
        while ((i = inputStream.read()) != -1) {
            System.out.print((char) i);
        }
        inputStream.close();//关闭输入流
    }
}
